{extend name="public/r_base"}

{block name="title"}
申请摩邦维修店
{/block}

{block name="style"}
{css href="/static/wechat/css/index.css" /}
{css href="/static/wechat/popo/css/shop.css" /}
{/block}

{block name="body"}
<style type="text/css">
    .msg_panel{position:fixed;top:0px;left:100%;width:100%;height:100%;background:#fff;overflow:auto;z-index:99;}
    .weui-popup__overlay{opacity:1;}
    .weui-dialog__btn{color:#0bb20c;font-size:0.8rem;}
    .weui-dialog, .weui-toast{box-shadow:0 0 3px 0 #000;}
    .g-scsfz-div{
        height: 13.5rem;
        background-color: #ffffff;
        display: flex;
        flex-wrap: wrap;
        /* justify-content: space-around; */
        align-items: center;
    }
    .scsfz{
        width: 40%;
        height: 6rem;
        /*background-color: #333333;*/
        margin: 0px .64rem;
        text-align: center;
    }
    .scsfz>i{
        position: relative;
        display: block;
        width: 100%;
        height: 80%;
        background-size: 100% 100%;
    }
    .sczmsfz{
        background-size: 100% 100%;
    }
    .scsfz3{
        float: left;
        position: absolute;
        margin-right: 9px;
        margin-bottom: 9px;
        width: 50px;
        height: 50px;
        border-radius: 100%;
        border: 1px solid #d9d9d9;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
        background-color: #ffffff;
    }
    .weui-uploader__input-box:before{
        width: 2px;
        height: 25.5px;
        background-color: #40a8ff;
    }
    .weui-uploader__input-box:after {
        width: 25.5px;
        height: 2px;
        background-color: #40a8ff;
    }
    .sczmsfz{
        background: url(/static/wechat/images/weirenzhen_03.png);
    }
    .zmsfz{
        background: url(/static/wechat/images/weirenzheng_05.png);
    }
    .sfzfm{
        background: url(/static/wechat/images/weirenzheng_09.png);
    }
    .img_yyzz{
        background: url(/static/wechat/images/shop_ying_03.jpg);
    }
    .weui-popup__overlay {
        opacity: 1;
    }
    /*添加图片*/
    #addimg{
        width: 43%;
        height: 18%;
        margin: auto;
        position: absolute;
        right: 5%;
        opacity: 0;
    }
    .navbar{
        position: relative;
        width: 100%;
        height: 25rem;
        background-color: #FFFFFF;
    }
    .tjimg>img{
        width: 3.5rem;
        height: 3.5rem;
        margin: 15px 0px 0px 20px;
        float: left;
    }
    #marg{
        margin: 15px 0px 0px 20px;
    }
    .tjtu{
        display: block;
        width: 85%;
        border: none;
        height: 2rem;
        margin: 0 auto;
        margin-top: 19rem;
        color: #ffffff;
        background-color: #fc4208;
        border-radius: 5px;
    }
</style>
<form action="{:url('r_certification/certification')}" id="audit_form" onsubmit="return false;">

<div class="pageControl startShop bg-f8">
    <div class="nav">
        <div class="msui_navTop">
            <a class="msui_navTop-back" href="javascript:;" onclick="if(window.confirm('确定退出?')){history.back();}"><i class="micon-back_fff"></i></a>
            <h1 class="msui_navTop-title">摩邦维修店</h1>
        </div>
    </div>

    <div class="prove" style="display:block;">
        <div class="weui-cell bg-f8">
            <p class="weui-cell__hd cl-3333">店铺信息</p>
        </div>
        <div class="weui-cell bg-ff">
            <p class="weui-label cl-3333">店铺logo</p>
            <p class="list_img">
                <img id="uploaderInput0_img" src="{$repair.logo|get_img_url}" style="vertical-align:top;width:1.5rem;height:1.5rem;border-radius:50%;" alt=""/>
                <input id="uploaderInput0" class="weui-uploader__input" type="file" accept="image/*"  file-attr="" />
                <input name="s_logo" type="hidden" value="{$repair.logo|default=''}" />
            </p>
        </div>
        <div class="weui-cell bg-ff">
            <div class="weui-cell__hd">
                <label class="weui-label cl-3333">店铺名称</label>
            </div>
            <div class="weui-cell__bd">
                <input name="s_repair_name" type="text" class="weui-input" placeholder="请输入店铺名称" value="{$repair.repair_name|default=''}" />
            </div>
        </div>
        <div class="weui-cells bg-ff">
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">联系电话</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_phone" type="tel" class="weui-input" placeholder="请输入电话号码" value="{$repair.phone|default=$member.phone}" />
                </div>
            </div>
            <!--<div class="weui-cell weui-cell_access">-->
                <!--<div class="weui-cell__hd">-->
                    <!--<label class="weui-label cl-3333">店铺地区</label>-->
                <!--</div>-->
                <!--<div class="weui-cell__bd">-->
                    <!--<input name="s_shengshiqu" type="text" class="weui-input" placeholder="省 市 区"/>-->
                    <!--<input name="s_province" type="hidden" value="{$repair.province|default=''}" />-->
                    <!--<input name="s_city" type="hidden" value="{$repair.city|default=''}" />-->
                    <!--<input name="s_area" type="hidden" value="{$repair.area|default=''}" />-->
                <!--</div>-->
                <!--<div class="weui-cell__ft"></div>-->
            <!--</div>-->
            <!--<div class="weui-cell weui-cell_access">-->
                <!--<div class="weui-cell__hd">-->
                    <!--<label class="weui-label cl-3333">街道</label>-->
                <!--</div>-->
                <!--<div class="weui-cell__bd">-->
                    <!--<select name="s_street" class="weui-select" data="{$repair.street|default=''}" style="height:1rem;line-height:1rem;padding-left:0px;font-size:0.7rem;">-->
                        <!--<option value="{$repair.street|default=''}">请选择...</option>-->
                    <!--</select>-->
                <!--</div>-->
                <!--<div class="weui-cell__ft"></div>-->
            <!--</div>-->
            <input type="hidden" name="s_province" value="" />
            <input type="hidden" name="s_city" value="" />
            <input type="hidden" name="s_area" value="" />
            <input type="hidden" name="s_street" value="" />

            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">店铺地址</label>
                </div>
                <div class="weui-cell__bd">
                    <input id="contact_address" type="text" class="weui-input" placeholder="请输入详细地址" value="" readonly />
                </div>
            </div>
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">街道</label>
                </div>
                <div class="weui-cell__bd">
                    <input id="street" type="text" class="weui-input" placeholder="街道" value="" readonly />
                </div>
            </div>
            <div class="weui-cell weui-cell_access shop_site">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">详细地址</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_address" type="text" class="weui-input" placeholder="请输入详细地址" value="{$repair.address|default=''}" />
                    <img id="box_map_open" src="/static/wechat/images/shop_logo_07.jpg" alt="" />
                </div>
            </div>

        </div>
        <div class="weui-cells">
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">店铺门面</label>
                </div>
                <div class="weui-cell__bd">
                    <a id="s_menmian" href="javascript:;" class="weui-input open-popup" style="display:block;color:#999;width:100%;" data-target="#Popup1" >请上传（选填）</a>
                    <!--<input id="s_menmian" type="text" class="weui-input open-popup" data-target="#Popup1" placeholder="请上传（选填）" readonly />-->
                </div>

            </div>
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">环境图</label>
                </div>
                <div class="weui-cell__bd">
                    <a id="s_huanjing" href="javascript:;" class="weui-input open-popup" style="display:block;color:#999;width:100%;" data-target="#Popup2" >请上传（选填）</a>
                    <!--<input id="s_huanjing" type="text" class="weui-input open-popup" data-target="#Popup2" placeholder="请上传（选填）" readonly />-->
                </div>
            </div>

        </div>
        <div class="shop_btn">
            <a id="s_next_but_no" style="background:#999;" href="javascript:;" class="weui-btn">下一步</a>
            <a id="s_next_but" style="display:none" href="javascript:;" onclick="$('#s_zizhi_box').animate({'left':'0'});" class="weui-btn">下一步</a>
        </div>
    </div>

</div>



<div id="s_zizhi_box" class="msg_panel">
    <div class="pageControl startShop bg-f8">
        <div class="nav">
            <div class="msui_navTop">
                <a class="msui_navTop-back" href="javascript:;" onclick="$('#s_zizhi_box').animate({'left':'100%'});"><i class="micon-back_fff"></i></a>
                <h1 class="msui_navTop-title">摩邦维修店</h1>
            </div>
        </div>
        <div class="shop_card" style="display: block">
            <div class="weui-cell bg-f8">
                <p class="weui-cell__hd cl-3333">资质信息</p>
            </div>
            <div class="weui-cell bg-ff">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">姓名</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_proposer" type="text" class="weui-input" placeholder="请输入您身份证上的姓名" value="{$repair.proposer|default=''}" />
                </div>
            </div>
            <div class="weui-cell bg-ff">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">身份证号</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_card_no" type="text" class="weui-input" placeholder="请输入您的身份证号" value="{$repair.card_no|default=''}" />
                </div>
            </div>
            <div class="weui-cell bg-f8">
                <p class="weui-cell__hd cl-3333">身份证照片</p>
            </div>
            <div class="shop_card_img bg-ff">
                <div class="g-scsfz-div">
                    <div class="scsfz">
                        <i class="sczmsfz" {notempty name='repair.id_card_in_hand'}style="background:url({$repair.id_card_in_hand}) no-repeat"{/notempty} >
                        <div class="weui-uploader__input-box scsfz3">
                            <input id="uploaderInput1" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                            <input type="hidden" name="s_id_card_in_hand" value="{$repair.id_card_in_hand|default=''}" />
                        </div>
                        </i>
                        <p>手持身份证正面照片</p>
                    </div>

                    <div class="scsfz">
                        <i class="zmsfz" {notempty name='repair.id_card_front'}style="background:url({$repair.id_card_front}) no-repeat"{/notempty} >
                        <div class="weui-uploader__input-box scsfz3">
                            <input id="uploaderInput2" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                            <input type="hidden" name="s_id_card_front" value="{$repair.id_card_front|default=''}" />
                        </div>
                        </i>
                        <p>身份证正面照片</p>
                    </div>

                    <div class="scsfz" style="margin-top: -1rem;">
                        <i class="sfzfm" {notempty name='repair.id_card_verso'}style="background:url({$repair.id_card_verso}) no-repeat"{/notempty} >
                        <div class="weui-uploader__input-box scsfz3">
                            <input id="uploaderInput3" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                            <input type="hidden" name="s_id_card_verso" value="{$repair.id_card_verso|default=''}" />
                        </div>
                        </i>
                        <p>身份证反面照片</p>
                    </div>
                </div>
                <!--<div class="shop_card_img_a">-->
                <!--<img src="/static/wechat/images/weirenzheng_05.png" alt=""/>-->
                <!--<p class="text-center">身份证正面照片</p>-->
                <!--</div>-->
                <!--<div class="shop_card_img_a">-->
                <!--<img src="/static/wechat/images/weirenzheng_09.png" alt=""/>-->
                <!--<p class="text-center">身份证反面照片</p>-->
                <!--</div>-->
                <!--<div class="shop_card_img_a">-->
                <!--<img src="/static/wechat/images/weirenzhen_03.png" alt=""/>-->
                <!--<p class="text-center">手持身份证正面照片</p>-->
                <!--</div>-->
            </div>
            <div class="weui-cell"></div>
            <div class="weui-cell bg-ff">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">注册号</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_business_license_num" type="text" class="weui-input" placeholder="请输入营业执照的注册号" value="{$repair.business_license_num|default=''}" />
                </div>
            </div>
            <div class="weui-cell bg-ff">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">执照名称</label>
                </div>
                <div class="weui-cell__bd">
                    <input name="s_business_license_name" type="text" class="weui-input" placeholder="请输入营业执照名称" value="{$repair.business_license_name|default=''}" />
                </div>
            </div>
            <div class="weui-sell_card bg-ff">
                <div class="weui-cell__hd">
                    <label class="weui-label cl-3333">营业执照照片</label>
                </div>

                <div class="scsfz">
                    <i class="img_yyzz" {notempty name='repair.business_license'}style="background-image:url({$repair.business_license})"{/notempty} >
                    <div class="weui-uploader__input-box scsfz3">
                        <input id="uploaderInput4" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                        <input type="hidden" name="s_business_license" value="{$repair.business_license|default=''}" />
                    </div>
                    </i>
                </div>
                <!--<div class="shop_card_img_a">-->
                <!--<img src="/static/wechat/images/shop_ying_03.jpg" alt=""/>-->
                <!--</div>-->
                <input name="s_lat" value="{$repair.lat|default=0}" type="hidden" />
                <input name="s_lon" value="{$repair.lon|default=0}" type="hidden" />
            </div>
            <div class="shop_btn shop_card_btn">
                <a href="javascript:;" class="weui-btn" id="s_btn_submit" style="display:none">提交审核</a>
                <a href="javascript:;" class="weui-btn" id="s_btn_submit_no" style="background:#999;">提交审核</a>
                <p>提交营业执照的好处</p>
                <p class="cl-9999"> * 摩邦优先推荐，更多流量支持</p>
                <p class="cl-9999"> * 认证信息展示，客户更多信任</p>
            </div>
        </div>
    </div>
</div>



<!--弹出框-->
<div id="Popup1" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="navbar">
            <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
                <a class="msui_navTop-back" onclick="$('#Popup1 .weui-popup__overlay').trigger('click');"><i class="micon-back"></i></a>
                <h1 class="msui_navTop-title">店铺门面</h1>
            </div>
            <div class="tjimg">
                <div class="shop_succ">
                    <div class="shop_store_img">
                        <div class="shop_store_img1">
                            <div class="scsfz" style="width:100%;height:9rem;margin:0;">
                                <i class="img_menmian" {notempty name='repair.business_license'}style="height:100%;background-image:url({$repair.cover})"{else}style="height:100%;"{/notempty} >
                                <div class="weui-uploader__input-box scsfz3">
                                    <input id="uploaderInput_1" class="weui-uploader__input one_upload" type="file" accept="image/*"  file-attr="" />
                                    <input type="hidden" name="s_cover" value="{$repair.cover|default=''}" />
                                </div>
                                </i>
                            </div>
                        </div>
                    </div>
                    <div class="shopStart_txt shopStart_txt_top">
                        <p class="cl-3333" style="text-align:left;text-indent:1.6rem;">请上传清晰的门店招牌图片，招牌要与商家名称一致，不要有水印，LOGO，二维码，地址，电话等。不要上传效果图或PS图等非真实图片</p>
                    </div>
                    <div class="shop_btn" id="shopStart_btn">
                        <a href="javascript:;" onclick="$('#Popup1 .weui-popup__overlay').trigger('click');" class="weui-btn">确定</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="Popup2" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="navbar">
            <div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
                <a class="msui_navTop-back" onclick="$('#Popup2 .weui-popup__overlay').trigger('click');"><i class="micon-back"></i></a>
                <h1 class="msui_navTop-title">添加图片</h1>
            </div>
            <div class="tjimg">
                {notempty name='repair.environment_img1'}
                <img src="{$repair.environment_img1}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='repair.environment_img2'}
                <img src="{$repair.environment_img2}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='repair.environment_img3'}
                <img src="{$repair.environment_img3}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='repair.environment_img4'}
                <img src="{$repair.environment_img4}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='repair.environment_img5'}
                <img src="{$repair.environment_img5}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='repair.environment_img6'}
                <img src="{$repair.environment_img6}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='repair.environment_img7'}
                <img src="{$repair.environment_img7}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                {notempty name='repair.environment_img8'}
                <img src="{$repair.environment_img8}" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />
                {/notempty}
                <div class="weui-uploader__input-box" id="marg">
                    <input id="uploaderInput_2" class="weui-uploader__input" type="file" accept="image/*"  file-attr="" />
                </div>
            </div>
            <input name="s_environment_img1" type="hidden" value="" />
            <input name="s_environment_img2" type="hidden" value="" />
            <input name="s_environment_img3" type="hidden" value="" />
            <input name="s_environment_img4" type="hidden" value="" />
            <input name="s_environment_img5" type="hidden" value="" />
            <input name="s_environment_img6" type="hidden" value="" />
            <input name="s_environment_img7" type="hidden" value="" />
            <input name="s_environment_img8" type="hidden" value="" />

            <button class="tjtu" onclick="$('#Popup2 .weui-popup__overlay').trigger('click');return false;">确认</button>
            <p style="clear:both;text-align:center;font-size:12px;color:#999;line-height:1rem;">（长按图片删除）</p>
        </div>
    </div>
</div>

</form>






<!-- loading toast -->
<div id="loadingToast" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast" style="opacity: 1; visibility: visible;">
        <i class="weui-loading weui-icon_toast"></i>
        <p class="weui-toast__content">加载中...</p>
    </div>
</div>
<div id="iosDialog2" class="js_dialog" style="display:none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__bd">弹窗内容，告知当前状态、信息和解决方法，描述文字尽量控制在三行内</div>
        <div class="weui-dialog__ft">
            <a href="javascript:$('#iosDialog2').hide();" class="weui-dialog__btn weui-dialog__btn_primary">知道了</a>
        </div>
    </div>
</div>

<!--map-->
<div id="box_map" style="display:none;position:fixed;top:0;left:0;z-index:9999;width:100%;height:100%;">
    <div id="container" tabindex="0" style="display:block;position:absolute;top:0;left:0;z-index:9999;width:100%;height:100%;"></div>
    <img id="box_map_close" src="/static/wechat/images/radio.png" style="position:absolute;right:10px;bottom:10px;z-index:9999;" />
    <img src="http://webapi.amap.com/theme/v1.3/markers/n/mark_r.png" style="display:block;position:absolute;top:50%;left:50%;z-index:9999;width:19px;height:31px;margin:-31px 0 0 -9px;" />
</div>


{/block}
{block name="javascript"}
{js href="/static/wechat/js/index.js" /}
{js href="/static/wechat/jquery_weui/js/data-picker1.js" /}
{js href="/static/wechat/jquery_weui/js/city-picker.js" /}
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=9a8d0d7e358d9d80f7f61a1989ba35a0"></script>
<script>
//改写原生的对话框
function sAlert(s){
    $('#iosDialog2').show();
    $('#iosDialog2 .weui-dialog__bd').html(s);
}
window.alert = function(s){sAlert(s);}


var s_submit_but_check = window.setInterval(function(){

    if(
        $('input[name="s_logo"]').val().length<15
        || $('input[name="s_repair_name"]').val().length<2
        || $("input[name='s_phone']").val().length<6
//        || $('input[name="s_province"]').val()==""
//        || $('input[name="s_city"]').val()==""
//        || $('input[name="s_area"]').val()==""
//        || $('select[name="s_street"]').val()==""
        || $('input[name="s_address"]').val()==""
    ){
        $('a#s_next_but_no').show();
        $('a#s_next_but').hide();
    }else{
        $('a#s_next_but_no').hide();
        $('a#s_next_but').show();
    }
    if(
        $('input[name="s_proposer"]').val().length<2
        || $('input[name="s_card_no"]').val().length<18
        || $('input[name="s_id_card_in_hand"]').val().length<15
        || $('input[name="s_id_card_front"]').val().length<15
        || $('input[name="s_id_card_verso"]').val().length<15
        || $('input[name="s_business_license_num"]').val().length<2
        || $('input[name="s_business_license_name"]').val().length<2
        || $('input[name="s_business_license"]').val().length<15
    ){
        $('a#s_btn_submit_no').show();
        $('a#s_btn_submit').hide();
    }else{
        $('a#s_btn_submit_no').hide();
        $('a#s_btn_submit').show();
    }
},800);

//长按删除图片
function del_uploads_img(o){
    window.t_img = o;
    window.t_uploads = setTimeout(function(){
        if(window.confirm("确定删除?")){
            var formData = new Object();
            formData.img = '/uploads/'+window.t_img.src.split('/uploads/')[1];
            $.ajax({
                url: '{:url("Base/del_upload_img")}' ,
                type: 'POST',
                data: formData,
                dataType:"json",
                success: function (d) {
                    if(d.code==200){
                        window.t_img.parentNode.removeChild(window.t_img);
                    }else{
                        alert('无法删除文件');
                    }
                },
                error: function (d) {
                    alert('网络异常');
                }
            });

        }
    },666);
}
//取消长按删除图片
function del_uploads_img_clear(){
    window.clearTimeout(window.t_uploads);
}

//处理定位信息
function onComplete(data){
    //point	Point	坐标点。
    //accuracy	Number	定位精确程度，单位为米。
    if(data.info=="SUCCESS"){
        $('input[name="s_lat"]').val(data.position.lat);
        $('input[name="s_lon"]').val(data.position.lng);
        map_get_address();
    }else{
        onError();
    }
}

//处理定位出错信息
function onError(e){
    $.confirm("没有获取到您的位置信息<br>是否重新获取?","位置信息",function(){
        window.location.reload();
    },function(){
        return false;
    });
}

function map_get_address(){
    $('#loadingToast').fadeIn();
    $.ajax({
        type:"get",
        cache:false,
        dataType:"json",
        url:"{:url('Base/map_get_address')}?lat="+$('input[name="s_lat"]').val()+"&lng="+$('input[name="s_lon"]').val(),
        error:function(s){
            $('#loadingToast').fadeOut();
        },
        success:function(d){
            $('#loadingToast').fadeOut();
            window.console.log(d);
            if(d.status==1){
                var address_array = d.regeocode.addressComponent;
                $('input[name="s_province"]').val(address_array.province);
                $('input[name="s_city"]').val(address_array.city);
                $('input[name="s_area"]').val(address_array.district);
                $('input[name="s_street"]').val(address_array.township);

                $('#contact_address').val(address_array.province + address_array.city + address_array.district);
                $('#street').val(address_array.township);

                var tmpAddress = d.regeocode.formatted_address;//.split(d.regeocode.addressComponent.township)[1];
                var newstr=tmpAddress.replace(address_array.province + address_array.city + address_array.district + address_array.township, "");
                $('input[name="s_address"]').val(newstr);
            }else{
                alert(d.info);
            }
        }
    });
}

//上传门面和环境图片 相应的文本框应该修改placeholder来提示
var uploads_placeholder = window.setInterval(function(){
    if($('input[name="s_cover"]').val()){
        $('#s_menmian').text("(已上传)");
    }
    if($("#Popup2 .tjimg img").length>0){
        $('#s_huanjing').text("(已上传"+$("#Popup2 .tjimg img").length+"张)");
    }else{
        $('#s_huanjing').text("请上传（选填）");
    }
},999);



//大波写的
$('#shopStart_btn').click(function (e) {
    e.preventDefault();
    $('.shopStart').removeClass('active');
    $('.prove').addClass('active');
});
$('.prove .shop_btn').click(function (e) {
    e.preventDefault();
    $('.prove').removeClass('active');
    $('.shop_card').addClass('active');
});
$('.msui_navTop-back').click(function(e){
    e.preventDefault();
    $('.active').removeClass('active')
            .prev().addClass('active');
});

//地图选择定位经纬度
$('#box_map_open').click(function(){
    $('#box_map').css("display","block");
    $('#box_map').css("height",$(window).height());
});
$('#box_map_close').click(function(){
    $('#box_map').css("display","none");
});
$('#contact_address').click(function () {
    $('#box_map').css("display","block");
    $('#box_map').css("height",$(window).height());
});
$('#street').click(function () {
    $('#box_map').css("display","block");
    $('#box_map').css("height",$(window).height());
});


//初始化地图
mapObj = new AMap.Map('container',{
    resizeEnable: true,
    zoom: 15
    //zoomEnable: false,	//禁止放大缩小
    //dragEnable: false,	//禁止拖动
});


//if(!$('input[name="s_address"]').val()) {
    //监控用户位置
    mapObj.plugin('AMap.Geolocation', function () {
        geolocation = new AMap.Geolocation({
            enableHighAccuracy: true,//是否使用高精度定位，默认:true
            timeout: 30000,          //超过30秒后停止定位，默认：无穷大
            maximumAge: 0,           //定位结果缓存0毫秒，默认：0
            convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
            showButton: true,        //显示定位按钮，默认：true
            buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
            buttonOffset: new AMap.Pixel(10, 10),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
            showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
            showCircle: false,        //定位成功后用圆圈表示定位精度范围，默认：true
            panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
            zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            extensions: 'base'
        });
        //markerOptions: window.my_dingdan,
        mapObj.addControl(geolocation);//开始监控
        AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息//onComplete
        AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
        $(".amap-geo").trigger("click");
    });
//}else{
//    if($('input[name="s_lat"]').val()!="" && $('input[name="s_lon"]').val()!=""){
//        mapObj.setCenter(new AMap.LngLat($('input[name="s_lon"]').val(),$('input[name="s_lat"]').val()));
//    }
//}


//开始拖拽地图时
mapObj.on("dragstart", function(){
    window.clearTimeout(window.dragTime);
});
//拖拽地图过程中
mapObj.on("dragging", function(){
    //window.clearTimeout(window.dragTime);

});
//停止拖拽地图时
mapObj.on("dragend", function(){
    window.dragTime = setTimeout(function() {
        var tmp = mapObj.getCenter();console.log(tmp);
        $('input[name="s_lat"]').val(tmp.lat);
        $('input[name="s_lon"]').val(tmp.lng);
        map_get_address();
    },666);
});


$("#uploaderInput0").change(function(){
    $('#loadingToast').show();

    window.setTimeout(function(){
        var formData = new FormData();
        formData.append("type","logo");
        formData.append("img",$("#uploaderInput0")[0].files[0]);
        $.ajax({
            url: '{:url("Base/get_upload_img")}' ,
            type: 'POST',
            data: formData,
            async: false,
            cache: true,
            contentType: false,
            processData: false,
            dataType:"json",
            success: function (d) {
                $('#loadingToast').fadeOut();
                if(!d.code){
                    alert(d.msg);
                }else{
                    $("input[name='s_logo']").val(d.data.path);
                    $("#uploaderInput0_img").attr('src', SCOPE.image_host_url+d.data.path);
                }
            },
            error: function (d) {
                $('#loadingToast').fadeOut();alert('网络异常');
            }
        });
    },666);

});
//添加图片
$("#uploaderInput_2").change(function(){
    if($("#Popup2 .tjimg img").length>7){
        alert('只能添加8张图片');
    }else{
        $('#loadingToast').show();
        window.setTimeout(function(){
            var formData = new FormData();
            formData.append("type","repair");
            formData.append("img",$("#uploaderInput_2")[0].files[0]);
            $.ajax({
                url: '{:url("Base/get_upload_img")}' ,
                type: 'POST',
                data: formData,
                async: false,
                cache: true,
                contentType: false,
                processData: false,
                dataType:"json",
                success: function (d) {
                    $('#loadingToast').fadeOut();
                    if(!d.code){
                        alert(d.msg);
                    }else{
                        $("#Popup2 .tjimg").prepend('<img src="'+SCOPE.image_host_url+d.data.path+'" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />');
                    }
                },
                error: function (d) {
                    alert('网络异常');$('#loadingToast').fadeOut();
                }
            });
        },666);

    }
});

/*
var num1 = parseInt($('input[name="s_province"]').val());
var num2 = parseInt($('input[name="s_city"]').val());
var num3 = parseInt($('input[name="s_area"]').val());
if( num1 && num2 && num3 ){
    for(i=0;i<$.mob_data_picker1.length;i++){
        if($.mob_data_picker1[i].code==num1){
            var num1 = i;
            var str1 = $.mob_data_picker1[i].name;
        }
    }
    for(i=0;i<$.mob_data_picker1[num1].sub.length;i++){
        if($.mob_data_picker1[num1].sub[i].code==num2){
            var num2 = i;
            var str2 = $.mob_data_picker1[num1].sub[i].name;
        }
    }
    for(i=0;i<$.mob_data_picker1[num1].sub[num2].sub.length;i++){
        if($.mob_data_picker1[num1].sub[num2].sub[i].code==num3){
            var num3 = i;
            var str3 = $.mob_data_picker1[num1].sub[num2].sub[i].name;
        }
    }
    $("input[name='s_shengshiqu']").val(str1+' '+str2+' '+str3);
}
$("input[name='s_shengshiqu']").cityPicker({
    title: "选择省市区",
    onChange: function (picker, values, displayValues) {
        return false;
    },
    onClose: function(r1){

        $("input[name='s_province']").val(r1.value[0]);
        $("input[name='s_city']").val(r1.value[1]);
        $("input[name='s_area']").val(r1.value[2]);

        $('#loadingToast').fadeIn();
        $.ajax({
            type:"get",
            cache:false,
            dataType:"json",
            url:"{:url('Base/get_street')}?area="+r1.value[2]+"",
            error:function(s){
                $('#loadingToast').fadeOut();
                alert('网络异常');
            },
            success:function(d){
                $('#loadingToast').fadeOut();
                if(d.code!=200){
                    alert(d.msg);
                }else{

                    var defaultData = $('select[name="s_street"]').attr("data");
                    var html = [];
                    var data = d.data;
                    var len = data.length;
                    html.push('<option value="">请选择...</option>');
                    for (var i = 0; i < len; i++) {
                        if(defaultData==data[i].region_id){
                            html.push("<option value='"+ data[i].region_id +"' selected='selected'>"+ data[i].region_name +"</option>");
                        }else{
                            html.push("<option value='"+ data[i].region_id +"'>"+ data[i].region_name +"</option>");
                        }
                    }
                    $("select[name='s_street']").html(html.join(''));

                }
            }
        });

    }
});
//获取一下省市区对应的data-codes
if($("input[name='s_shengshiqu']").val()) {
    $("input[name='s_shengshiqu']").data().picker.open();
    $("input[name='s_shengshiqu']").data().picker.close();
}
*/





$("input.one_upload[type='file']").change(function () {
    upload_id_card($(this));
});

//  提交申请
$("#s_btn_submit").click(function (e) {
    var tmpImg = $("#Popup2 .tjimg img");
    for(i=0;i<tmpImg.length;i++){
        $("input[name='s_environment_img"+(i+1)+"']").val( '/uploads/'+tmpImg[i].src.split('/uploads/')[1] );
    }
    var f = $("#audit_form");
//    if(!audit_check_form(f)){
//        return false;
//    }
    $('#loadingToast').fadeIn();
    e.preventDefault();
    $.ajax({
        type : 'POST',
        url : f.attr('action'),
        data : f.serialize(),
        dataType : 'json',
        success : function (msg) {
            $('#loadingToast').fadeOut();
            console.log(msg);
            if (msg.code == 200) {
                var tmpUrl = "{:url('audit_status', ['status' => 1])}";
                //alert(tmpUrl)
                window.location.href=tmpUrl;
            } else {
                var code = msg.code;
                $.alert(error_code[code]);
            }
        }
    });
});



//提交前验证
//function audit_check_form(f){
//    if( parseInt(f.find("[name='s_lat']").val())<1 || parseInt(f.find("[name='s_lon']").val())<1 ){
//        alert('无法获取您的位置,请重新访问.');return false;
//    }
//
//    if(f.find("[name='s_logo']").val().length<15){
//        alert('请上传店铺logo');return false;
//    }
//    if(f.find("[name='s_repair_name']").val().length<3){
//        alert('请填写店铺名称');return false;
//    }
//    var isMobile=/^(?:13\d|15\d)\d{5}(\d{3}|\*{3})$/;
//    var isPhone=/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
//    if( !isMobile.test(f.find("[name='s_phone']").val()) && !isPhone.test(f.find("[name='s_phone']").val()) ){
//        alert("请正确填写电话号码");
//        return false;
//    }
//    if( !f.find("[name='s_province']").val()
//            || !f.find("[name='s_city']").val()
//            || !f.find("[name='s_area']").val()
//            || !f.find("[name='s_street']").val()
//            || f.find("[name='s_address']").val().length<3
//    ){
//        alert('请选择店铺地区的省市区街道和地址');return false;
//    }
//    if( f.find("[name='s_proposer']").val().length<2 ){
//        alert('请输入您身份证上的姓名');return false;
//    }
//    if( f.find("[name='s_card_no']").val().length!=18 ){
//        alert('请输入您的身份证号');return false;
//    }
//    if( f.find("[name='s_id_card_in_hand']").val().length<15 ){
//        alert('请上传手持身份证正面照片');return false;
//    }
//    if( f.find("[name='s_id_card_front']").val().length<15 ){
//        alert('请上传身份证正面照片');return false;
//    }
//    if( f.find("[name='s_id_card_verso']").val().length<15 ){
//        alert('请上传身份证反面照片');return false;
//    }
//    if( f.find("[name='s_business_license_num']").val().length<12 ){
//        alert('请输入营业执照的注册号');return false;
//    }
//    if( f.find("[name='s_business_license_name']").val().length<5 ){
//        alert('请输入营业执照名称');return false;
//    }
//    if( f.find("[name='s_business_license']").val().length<5 ){
//        alert('请上传营业执照照片');return false;
//    }
//
//    return true;
//}

</script>
{/block}